﻿using System.Windows.Forms;
using Alerter.DataSet;
using DevExpress.Utils;
using DevExpress.XtraEditors.Controls;

namespace Alerter.Controls
{
    public partial class QueryResultXtraForm : Form
    {
        public OperadoraDataSet OperatorData
        {
            set
            {
                operadoraDataSet.Merge(value);
                operatorRepositoryItemLookUpEdit.Columns.Clear();
                operatorRepositoryItemLookUpEdit.Columns.AddRange(new[] {
                    new LookUpColumnInfo("Id", "Id", 81, FormatType.None, "", false, HorzAlignment.Near),
                    new LookUpColumnInfo("Nome", "Nome", 85, FormatType.None, "", true, HorzAlignment.Near)});
                operatorRepositoryItemLookUpEdit.DataSource = operadoraDataSet.Operadora;
                operatorRepositoryItemLookUpEdit.DisplayMember = operadoraDataSet.Operadora.NomeColumn.ColumnName;
                operatorRepositoryItemLookUpEdit.ValueMember = operadoraDataSet.Operadora.IdColumn.ColumnName;
            }
        }

        public ContactoDataSet ContactsData
        {
            set
            {
                var dataSet = value;
                gridControl.DataSource = null;
                gridControl.DataSource = dataSet;
                gridControl.DataMember = dataSet.Contacto.TableName;
            }
        }

        public QueryResultXtraForm()
        {
            InitializeComponent();
        }
    }
}
